<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 5 6 1 13 2 9 10 12 19 20 12 un un
      
      const p = new Promise((resolve, reject) => {
        console.log(5) //
        resolve(13) // 标记为成功
        console.log(6) //
      })
      console.log(1) //
      setTimeout(function () {
        console.log(2) //
        setTimeout(() => {
          console.log(9) //
          new Promise(function (resolve) {
            console.log(10) //
          })
          console.log(12) //
        }, 100)
        setTimeout(() => {
          console.log(19) //
          new Promise(function (resolve) {
            console.log(20) //
            resolve()
          })
            .then((res) => {
              console.log(res)
            })
            .then((r) => {
              console.log(r)
            })
          console.log(12)
        }, 100)
      })
      p.then((res) => {
        console.log(res)
      })
    </script>
  </body>
</html>
